<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="jquery-1.11.0.js"></script>
	</head>
	<script type="text/javascript">
		$(function() {
			$('.btn').click(function() {
				if(!$('input').val()) {
					console.log('请输入手机号码');
				} else if(!$('input').val().match(/^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8]))\d{8}$/)) {
					console.log('请输入正确的手机号码');
				} else {
					var countdown = 10;
                    function settime(obj) {
						if(countdown == 0) {
							obj.removeAttribute("disabled");
							obj.innerHTML = "免费获取验证码";
							countdown = 10;
							return;
						} else {
							obj.setAttribute("disabled", true);
							if(countdown>=10){
								obj.innerHTML = "重新发送(" + countdown-- + "s)";
							}else{
								obj.innerHTML = "重新发送(0" + countdown-- + "s)";
							}
//							countdown--;
						}
						setTimeout(function() {
							settime(obj)
						}, 1000)
					}
                    console.log(this);
					settime(this);
				}
			})
		})
	</script>

	<body>
		<input type="text" name="" id="" value="" />
		<button class="btn">点击获取验证码</button>
	</body>

</html>